﻿using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace S.EarTag.Infrastructure.Repository.Impl.EarTagRepository
{
    public class BodyMeasureModelRepository : BaseRepository<BodyMeasureModel>, IBodyMeasureModelRepository
    {
        private readonly SqlSugarClient _db;
        public BodyMeasureModelRepository(SqlSugarClient db) : base(db)
        {
            _db = db;
        }
        /// <summary>
        /// 批量删除体尺测量数据
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public async Task<bool> BatchBodyMeasure(List<int> ids)
        {
            var result=await _db.Deleteable<BodyMeasureModel>().In(ids).ExecuteCommandAsync();
            return result > 0;
        }
        /// <summary>
        /// 根据可视耳号反填
        /// </summary>
        /// <param name="EarTag"></param>
        /// <returns></returns>
        public async Task<BodyMeasureModel> GetBoyEarTag(string? EarTag)
        {
            var result=await _db.Queryable<BodyMeasureModel>().SingleAsync(a=>a.EarTag==EarTag);
            return result;
        }
    }
}
